# _*_conding:cp-1252-*-
# 教育机构：银杰教育
# 讲师：李伟
# 开发时间：2025/9/2 下午10:53
import requests
from jsonpath import jsonpath
import config

url2 = "http://shop.lemonban.com:8107/prod/prodInfo"
url3 = "http://shop.lemonban.com:8107/p/shopCart/changeItem"

url = "http://shop.lemonban.com:8107/login"
metd = "post"
header = {"Content-Type": "application/json"}
param = {"principal": "13100009999",
         "credentials": "Admin521314",
         "appType": 3,
         "loginType": 0
         }
res = requests.request(url=url,method=metd,headers=header,json=param)
# print(res.text)

token = jsonpath(res.json(),"$..access_token")[0]
print(token)


# 商品搜索
url_search = "http://shop.lemonban.com:8107/search/searchProdPage"
metd = "get"
param = {"prodName": "圆筒包"}
resp = requests.request(method=metd, url=url_search, params=param)
# print(resp.text)
prodId = jsonpath(resp.json(),"$..prodId")[0]
print(prodId)

# # 商品详情接口
# 这个接口的参数 prodId 来自于商品搜索接口的返回值
url = "http://shop.lemonban.com:8107/prod/prodInfo"
param = {"prodId": prodId}
resp = requests.request(method=metd, url=url, params=param)
print(resp.json())
